from django.contrib import admin
from django.contrib.admin import AdminSite
from django.http import HttpResponse
from django.urls import path

from .models import *
from .views import index


# Register your models here.

class DummyModel(models.Model):
    class Meta:
        verbose_name = "自定义路由"
        verbose_name_plural = '自定义路由'
        app_label = 'business'


def my_custom_view(request):
    return HttpResponse('自定义路由，写自己的内容')


class DummyModelAdmin(admin.ModelAdmin):
    model = DummyModel

    def get_urls(self):
        view_name = '{}_{}_changelist'.format(
            self.model._meta.app_label, self.model._meta.model_name)
        return [
            path('settings/', my_custom_view, name=view_name),
        ]


admin.site.register(DummyModel, DummyModelAdmin)
admin.site.register(Author)
admin.site.register(Article)
